﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Util;

public partial class Upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void sendDataTracke_Click(object sender, EventArgs e)
    {
        if (TrackeUpload.HasFile)
        {
            string savePathForSave = string.Format(@"{0}audio-player\tracks\{1}", Request.PhysicalApplicationPath, Server.HtmlEncode(TrackeUpload.FileName));
            string savePathForDB = string.Format(@"audio-player/tracks/{0}", Server.HtmlEncode(TrackeUpload.FileName));
            TrackeUpload.SaveAs(savePathForSave);
            string ResMessage = "";
            new BLL.Tracks().SendTrack(new TrackInfo() { Name = TrackName.Text, Price = TrackePrice.Text, Author = HttpContext.Current.User.Identity.Name, FilePath = savePathForDB }, TrackeUpload, out ResMessage);
            StatusMessage.Text = ResMessage;
            //if (!ResMessage.Equals("Проблемы в названии трэка (разберитесь..)"))
            //{
            //}
        }
        else
        {
            StatusMessage.Text = "Вы не выбрали файл трэка!";
        }


    }
}
